# -*- coding:utf-8 -*-
import pymongo
def insertMG(gpcode,keys,value,desc):
    client = pymongo.MongoClient("182.61.20.41", 27017)
    db = client.dfcfdata
    db.baseinfo.insert({'_id': gpcode, keys: {"value":value,"desc":desc}})

def insertAndUpdate(gpcode,keys,value,desc):
    client = pymongo.MongoClient("182.61.20.41", 27017)
    db = client.dfcfdata
    db.baseinfo.update({'_id':gpcode}, {'$set':{keys: {"value":value,"desc":desc}}})

def insertYJDZ(gpcode,name,zf,ggtime):
    client = pymongo.MongoClient("182.61.20.41", 27017)
    db = client.dfcfdata
    try:
        db.yjdz.insert({'_id': gpcode,"name":name,"zf":zf,"ggtime":ggtime})
    except Exception as e:
        db.yjdz.update({'_id':gpcode}, {'$set':{"name":name,"zf":zf,"ggtime":ggtime}})
        print(e)
